package renderers
{
	import spark.components.IconItemRenderer;
	
	public class SampleItemRenderer extends IconItemRenderer
	{
		
		// Embed "general" icon
		[Embed(source="assets/icons/arrow.png")]
		private var iconGeneral:Class;
		
		// Embed "cache" icon
		[Embed(source="assets/icons/arrow_cache.png")]
		private var iconCache:Class;
		
		
		public function SampleItemRenderer()
		{
			//TODO: implement function
			super();
			super.labelField = "title";
			super.messageField = "message";
			super.iconField = "icon";
			super.iconHeight = 50;
			super.iconWidth = 70;
			
		}
		
		override public function set data(value:Object):void
		{
			// TODO Auto Generated method stub
			super.data = value;
			if(value != null)
			{
				super.data = value;
				var status:String  = "false";value.readed;
				var icon:Class;
				switch(status){
					case "true":
						icon = iconCache;
						break;
					case "false":
						icon = iconGeneral;
						break;
				}
				this.decorator = icon;
			}
		}
		
		override protected function layoutContents(unscaledWidth:Number, 
												   unscaledHeight:Number):void
		{
			super.layoutContents(unscaledWidth, unscaledHeight);
			// layout all the subcomponents here      		
			this.setElementSize(this.decorator,this.decorator.width,this.decorator.height);
			this.setElementPosition(this.decorator,this.decorator+20,this.decorator.y);
		}
	}
}